require(['../config'], () => {
    require(['template', 'header', 'footer'], (template) => {
        class login {
            constructor() {
                this.init()
            }
            init() {
                $('#loginBtn').on('click', (e) => {
                    const name = $('#inputUsrname').val()
                    const pwd = $('#inputPwd').val()
                    e.preventDefault()
                    $.get('http://localhost/php/login.php', { name, pwd }, resp => {
                        const code1 = JSON.parse(resp)
                        if (code1.code == 200) {
                            console.log(code1)
                                // $('.header-top-other:first-child').addClass('ac').next().removeClass('ac')

                            alert("登录成功,即将跳转到首页")
                                // console.log(code1.body.list[0].name)
                            $.cookie('name', code1.body.list[0].name, { expires: 3, path: '/' })
                                // console.log($.cookie('name'))

                            location.href = "/index.html"


                        }

                    })
                })
            }
        }
        return new login()
    })
})